package com.wsd.common.entity;

import cn.hutool.http.HttpStatus;

import java.util.HashMap;

public class ResponseEntity extends HashMap<String, Object> {

    public ResponseEntity() {
        put("code", 200);
        put("message", "success");
    }

    private ResponseEntity(Integer code, String message) {
        put("code", code);
        put("message", message);
    }

    public static ResponseEntity success() {
        return success("请求成功");
    }

    public static ResponseEntity success(String message) {
        return new ResponseEntity(HttpStatus.HTTP_OK, message);
    }


    public static ResponseEntity error() {
        return error("未知异常");
    }

    public static ResponseEntity error(String message) {
        return new ResponseEntity(HttpStatus.HTTP_INTERNAL_ERROR, message);
    }

    public static ResponseEntity error(Integer code, String message) {
        return new ResponseEntity(code, message);
    }

    public ResponseEntity put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
